AddComponentPostInit("combat", function(self)
    local old_GetAttacked = self.GetAttacked
    function self:GetAttacked(attacker,damage,weapon,stimuli,spdamage,...)
        if attacker and attacker.prefab then
            attacker.last_atk_weapon = weapon
        end
        return old_GetAttacked(self,attacker,damage,weapon,stimuli,spdamage,...)
    end
end)


AddComponentPostInit("health", function(self)
    local old_SetVal = self.SetVal
    function self:SetVal(val,cause,afflicter,...)
        local res = {old_SetVal(self,val,cause,afflicter,...)}
        if self:IsDead() then
            if afflicter and afflicter.last_atk_weapon and afflicter.last_atk_weapon.prefab and afflicter.last_atk_weapon.prefab == 'yuemiheng_spear' then
                -- 这里写一些限制条件
                local allow_to_continue = true
                if self.inst.prefab == 'klaus' then
                    if not self.inst:IsUnchained() then
                        allow_to_continue = false
                    end
                end
                
                if allow_to_continue then
                    local victim_lootdrop = self.inst.components.lootdropper
                    if victim_lootdrop then
                        local old_GenerateLoot = victim_lootdrop.GenerateLoot
                        function victim_lootdrop:GenerateLoot(...)
                            local res = old_GenerateLoot(self,...)
                            if type(res) == 'table' and #res > 0 then
                                local res_copy = deepcopy(res)
                                for _,v in pairs(res_copy) do
                                    table.insert(res, v)
                                end
                            end
                            return res
                        end
                    end
                end
            end
        end
        return unpack(res)
    end
end)